﻿<html>
<head>
    <title></title>
    <div id="themefile"></div>
    <style>
        @import "this://app/images/public.css";
        @import "images/form.css";

        html, body {
            width: *;
            height: *;
            overflow: hidden;
            margin: 0;
            padding: 0;
            background: color(center-background-color);
            color: color(general-text-color)
        }

        .wrapper {
            width: *;
            padding: 8 dip;
        }

        input,select{width:150dip}

    </style>
</head>
<body>
<div class="wrapper">
    <table>
        <tr>
            <td>{{BaseName}}：</td>
            <td><input type="text" id="name" value=""></td>
        </tr>
        <tr>
            <td>{{BaseYear}}：</td>
            <td><input type="text" id="year" value="" maxlength="4"></td>
        </tr>
        <tr>
            <td>{{BaseType}}：</td>
            <td>
                <select id="type" editable></select>
            </td>
        </tr>

        <tr>
            <td>{{BasePublisher}}：</td>
            <td>
                <select id="publisher" editable></select>
            </td>
        </tr>
        <tr>
            <td>{{BaseCountry}}：</td>
            <td>
                <select id="country" editable></select>
                
            </td>
        </tr>
        <tr>
            <td>{{BaseVersion}}：</td>
            <td>
            <select id="version" editable></select>
            </td>
        </tr>
        <tr>
            <td>{{BaseTranslate}}：</td>
            <td>
            <input type="text" id="translate">
            
            </td>
        </tr>

    </table>
</div>
<div class="form_bottom">
    <button class="cancel" id="close-dialog">{{Cancel}}</button>
    <button class="ok" id="submit">{{Confirm}}</button>
</div>

<script type="text/tiscript">
include ROOTPATH + "tis/utils.tis";

view.root.on("ready", function(){
    //初始化主题
    initUiTheme();
    
    //渲染语言
    createLang();
    view.windowCaption = CONF.Lang.EditBaseInfo;
    
    //填充列表
    var typeList = JSON.parse(mainView.GetRombaseEnumList("type"));
    var typeDom = "";
    for(var obj in typeList) {
        typeDom += "<option value='"+ obj +"'>"+obj+"</option>";
    }
    $(#type).options.html = typeDom;

    var publisherList = JSON.parse(mainView.GetRombaseEnumList("publisher"));
    var publisherDom = "";
    for(var obj in publisherList) {
        publisherDom += "<option value='"+ obj +"'>"+obj+"</option>";
    }
    $(#publisher).options.html = publisherDom;

    var countryList = JSON.parse(mainView.GetRombaseEnumList("country"));
    var countryDom = "";
    for(var obj in countryList) {
        countryDom += "<option value='"+ obj +"'>"+obj+"</option>";
    }
    $(#country).options.html = countryDom;

    var versionList = JSON.parse(mainView.GetRombaseEnumList("version"));
    var versionDom = "";
    for(var obj in versionList) {
        versionDom += "<option value='"+ obj +"'>"+obj+"</option>";
    }
    $(#version).options.html  = versionDom;

    //填充值
    var getjson = mainView.GetRomBase(view.parameters.id);
    if(getjson != undefined){
        var info = JSON.parse(getjson);
        if(info.Name != undefined && info.Name != ""){$(#name).value = info.Name;}
        if(info.Type != undefined && info.Type != ""){$(#type).value = info.Type;}
        if(info.Year != undefined && info.Year != ""){$(#year).value = info.Year;}
        if(info.Publisher != undefined && info.Publisher != ""){$(#publisher).value = info.Publisher;}
        if(info.Country != undefined && info.Country != ""){$(#country).value = info.Country;}
        if(info.Translate != undefined && info.Translate != ""){$(#translate).value = info.Translate;}
        if(info.Version != undefined && info.Version != ""){$(#version).value = info.Version;}
    }
    
});

event click $(#submit){
    var year = "";
    if($(#year).value != "" && $(#year).value != undefined){
         year = $(#year).value.toString();
    }else{
         year = "";
    }
    var data = {
        id:view.parameters.id;
        name:$(#name).value,
        year:year,
        type:$(#type).value,
        publisher:$(#publisher).value,
        country:$(#country).value,
        translate:$(#translate).value,
        version:$(#version).value,
    }
    var result = mainView.SetRomBase(JSON.stringify(data));
    view.close(result);
}

event click $(#close-dialog){
    view.close();
}



</script>

</body>
</html>